package com.wxx.notion;


import cn.hutool.core.bean.BeanUtil;
import com.wxx.bean.ProBean;
import com.wxx.contance.Contance;
import com.wxx.message.DingDingSender;
import com.wxx.message.IMessageSender;
import com.wxx.utils.TraceIdUtil;
import lombok.extern.slf4j.Slf4j;
import org.slf4j.MDC;

import java.io.File;
import java.io.FileInputStream;
import java.util.Properties;

/**
 * @author: wxx
 * @date: 2024-01-18 22:30
 * @description todo 描述信息
 */
@Slf4j
public class SendInfo {

    private static IMessageSender sender = new DingDingSender();

    public static void main(String[] args) throws Exception {
        try {
            String traceLogId = TraceIdUtil.getTraceLogId();
            MDC.put(Contance.TRACE_ID, traceLogId);
            Properties properties = new Properties();
            properties.load(new FileInputStream(new File(args[0])));
            ProBean proBean = new ProBean();
            BeanUtil.copyProperties(properties, proBean);
            proBean.setProperties(properties);
            //初始化发送器
            sender.init(proBean);
            sender.sendMessage(sender.getMsg());
        } finally {
            MDC.clear();
        }
    }
}
